/*
kalman.c
offer kalman filter function
designed by lunanting

-----------------------
2020-07-28 20:19:25
create file
-----------------------
*/
#ifndef __KALMAN_H
#define __KALMAN_H



/***********************************date type define*************************************/



//kalman class
typedef struct{
    int init;   //object init state
    double R;   //过程噪声，Q增大，动态响应变快，收敛稳定性变坏
    double Q;   //测量噪声，R增大，动态响应变慢，收敛稳定性变好
    double x_last;
    double x_mid;
    double x_now;
    double p_last;
    double p_mid;   
    double p_now;
    double kg;
    double input;   //滤波对象数据
    double (*filter)(void *,double);
    double (*filter_s)(void *);
}KALMAN_class;





/*******************************function extern******************************/
extern KALMAN_class *xp_kalman_init(double R,double Q); //kalman filter init
extern double xp_kalman_filter(KALMAN_class *obj,double data);  //kalman filter function
extern double xp_kalman_filter_s(KALMAN_class *obj);    //kalman filter use input



#endif
//end of the file
